package com.lagou.edu.controller;

import com.lagou.edu.service.EmailCodeService;
import com.lagou.edu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private EmailCodeService codeService;

    @GetMapping("/create/{email}")
    public Result createcode(@PathVariable String email) {
        return codeService.createCode(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public Integer validateCode(@PathVariable String email,@PathVariable String code) {
        return codeService.checkCode(email,code);
    }



}
